<template>
  <div class="coustom_pagination_main">
    <el-pagination
      :page-sizes="pageSizes"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="sizeChange"
      @current-change="currentPageChange"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  name: "coustomPagination",
  props: {
    total: {
      type: Number,
      default: 0,
    },
    pageSizes: {
      type: Array,
      default: function () {
        return [10, 20, 50, 100, 300];
      },
    },
  },
  components: {},
  data() {
    return {
      pageSize: "",
      currentPage: 1,
    };
  },
  created() {
    this.pageSize = this.pageSizes[0];
  },
  methods: {
    sizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.$emit("pageChange", this.pageSize, this.currentPage);
    },
    currentPageChange(val) {
      this.currentPage = val;
      this.$emit("pageChange", this.pageSize, this.currentPage);
    },
  },
  watch: {},
};
</script>

<style scoped lang="less">
.coustom_pagination_main {
  padding-top: 30px;
  text-align: right;
}
</style>
